package com.imooc.order.util;


import com.imooc.order.vo.ResultVO;

/**
 * ResultVO封装
 * @author steve
 * @date 2020/5/7 6:39 上午
 */
public class ResultVOUtil {

    /**
     * 成功返回，并且携带数据
     * @param object
     * @return
     */
    public static ResultVO success(Object object) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(0);
        resultVO.setMsg("成功");
        resultVO.setData(object);
        return resultVO;
    }

    /**
     * 成功返回，不带数据
     * @return
     */
    public static ResultVO success() {
        return success(null);
    }

    /**
     * 错误返回
     * @param code 错误码
     * @param msg 错误提示
     * @return
     */
    public static ResultVO error(Integer code, String msg) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(code);
        resultVO.setMsg(msg);
        return resultVO;
    }
}
